# PyJuggler is (C) Copyright 2002-2012 by Patrick Hartling
# Distributed under the GNU Lesser General Public License 2.1.  (See
# accompanying file COPYING.txt or http://www.gnu.org/copyleft/lesser.txt)

bindir=		@bindir@
prefix=		@prefix@
srcdir=		@srcdir@
topdir=		@topdir@
top_srcdir=	@top_srcdir@

ifeq (@OS_TYPE@, Win32)
   CXXFLAGS=	$(shell flagpoll vrjuggler --cflags) /Zm800 /GX /GR /Op	\
		/I$(srcdir) /I$(top_srcdir) /Zc:wchar_t,forScope	\
		$(CXXFLAGS_OPT)
   CXXFLAGS_DBG=/Z7 /Od /Ob0 /MDd /DPYJUGGLER_DEBUG /DJUGGLER_DEBUG
   CXXFLAGS_OPT=/Ogity /O2 /Gs /Ob2 /MD /DPYJUGGLER_OPT /DJUGGLER_OPT /DNDEBUG
   LDFLAGS_DBG=	/DEBUG
   LDFLAGS_OPT=	/RELEASE
   LDFLAGS=	$(LDFLAGS_OPT)
else
   CXXFLAGS=	$(shell flagpoll vrjuggler --cflags) -I$(srcdir)	\
		-I$(top_srcdir) $(CXXFLAGS_OPT)
   CXXFLAGS_DBG=-DPYJUGGLER_DEBUG -DJUGGLER_DEBUG -g
   CXXFLAGS_OPT=-DPYJUGGLER_OPT -DJUGGLER_OPT -DNDEBUG -O2
   LDFLAGS_DBG=	-g
   LDFLAGS_OPT=	-O2
ifeq (@PLATFORM@, Darwin)
   LDFLAGS=	--export-dynamic $(LDFLAGS_OPT)
else
   LDFLAGS=	-Wl,--export-dynamic $(LDFLAGS_OPT)
endif
endif

CXX=		@CXX@
CXXFLAGS+=	@PYTHON_INCLUDES@
LIBS=		$(shell flagpoll vrjuggler --get-all-libs)		\
		$(shell flagpoll vrjuggler-opengl --get-all-libs)
EXTRA_LIBS=	$(shell flagpoll vrjuggler --get-all-extra-libs)	\
		$(shell flagpoll vrjuggler-opengl --get-all-extra-libs)

#PYJUTIL_LIB=		-L$(topdir)/lib -lpyjutil

PYTHON_VERSION=		@PYTHON_VERSION@
#PYTHON_LIB=		@PYTHON_LIB_DBG@
PYTHON_LIB=		@PYTHON_LIB_OPT@
PYTHON_LDFLAGS=		@PYTHON_LDFLAGS@ $(PYTHON_LIB) @UTIL_LIB@	\
			@PYTHON_LIB_DEPS@				\
			$(NULL)
#BOOST_PYTHON_LDFLAGS=	@BOOST_PYTHON_LDFLAGS_DBG@
BOOST_PYTHON_LDFLAGS=	@BOOST_PYTHON_LDFLAGS_OPT@

EXEEXT=		@EXEEXT@
OBJEXT=		@OBJEXT@

SRCS=		main.cpp PyExtApp.cpp
OBJS=		$(SRCS:.cpp=.$(OBJEXT))
APP_NAME=	extApp$(EXEEXT)

vpath %.cpp $(srcdir)

all: $(APP_NAME)

$(APP_NAME): $(OBJS)
	$(CXX) -o $@ $(OBJS) $(LDFLAGS) $(PYJUTIL_LIB)			\
          $(BOOST_PYTHON_LDFLAGS) $(PYTHON_LDFLAGS) $(LIBS) $(EXTRA_LIBS)

%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $<

clean:
	rm -f $(OBJS)

clobber:
	$(MAKE) clean
	rm -f $(APP_NAME)
